Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tetragon: un/pin fixes #3079

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

tetragon: un/pin fixes #3079

wants to merge 13 commits into from

Conversation

olsajiri
Copy link
Contributor

@olsajiri olsajiri commented Nov 6, 2024

factor sensors unpin-ing

fixes #3033

Since linux kernel commit [1] we need to have O_RDWR to get link
object properly.

Use O_RDWR (nil for opts) in ebpf.LoadPinnedMap calls that face the
path for the first time and stumble on link pin and fail.

[1] 25fc94b2f02d bpf: link: Refuse non-O_RDWR flags in BPF_OBJ_GET
Signed-off-by: Jiri Olsa <[email protected]>
Now when we create link pins by default all sensor unloads remove link pin
and because bpf pinned links removal is asynchronous, we need to wait to be
sure it's gone.

Signed-off-by: Jiri Olsa <[email protected]>
Add proper 'override' suffix to the link path for kprobe multi
attach override link.

Signed-off-by: Jiri Olsa <[email protected]>
Add proper 'override' suffix to the link path for fmodret
attach override link.

Signed-off-by: Jiri Olsa <[email protected]>
It's not used.

Signed-off-by: Jiri Olsa <[email protected]>
Make sure we unpin link when closing the link.

Signed-off-by: Jiri Olsa <[email protected]>
Now when we remove pins when we unload sensor/program,
we can pin links unconditionally.

Signed-off-by: Jiri Olsa <[email protected]>
Store KeepSensorsOnExit flag in SensorManager and use it when
sensors go down to instruct sensor unload path to unpin or leave
all the pins (progs/maps/links).

The sensor level support comes in following change.

Signed-off-by: Jiri Olsa <[email protected]>
@olsajiri olsajiri added the release-note/minor This PR introduces a minor user-visible change label Nov 7, 2024
@olsajiri olsajiri force-pushed the pr/olsajiri/on_exit branch 3 times, most recently from ff5dab6 to fa5b10d Compare November 7, 2024 13:27
Propage unpin flag from sensor.Unload/Destroy down to the unloader level
and unpin progs/maps/links only when instructed by the unpin argument.

Signed-off-by: Jiri Olsa <[email protected]>
It unloads program and it fits better next to the existing
LinkUnloader type.

Signed-off-by: Jiri Olsa <[email protected]>
Use sensor manager with the new KeepSensorsOnExit setup
instead of loading sensors manually.

Signed-off-by: Jiri Olsa <[email protected]>
Add persistent enforcement test that simulates tetragon normal exit,
WITHOUT KeepSensorsOnExit and make sure the enforcement is removed.

Signed-off-by: Jiri Olsa <[email protected]>
Add persistent enforcement test that simulates enforcement policy unload
(not exit) with KeepSensorsOnExit and make sure the enforcement is removed.

Signed-off-by: Jiri Olsa <[email protected]>
@olsajiri olsajiri changed the title Pr/olsajiri/on exit tetragon: un/pin fixes Nov 7, 2024
@olsajiri olsajiri marked this pull request as ready for review November 7, 2024 14:30
@olsajiri olsajiri requested a review from a team as a code owner November 7, 2024 14:30
Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! The 2 sec sleeps in testing don't really look awesome though, isn't there a way to write something faster and more reliable?

run(1, expected)

// remove the policy and we should get rid of the enforcement
err = mgr.DeleteTracingPolicy(ctx, tp.TpName(), "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the commit you specify "test that simulates enforcement policy unload (not exit)" but you use Delete instead of DisableTracingPolicy, is that intended? You don't exactly test the scenario here #3033, maybe you want to modify one or add another one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, it should be about the same, but I can add that scenario as well, thnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option --keep-sensors-on-exit doesn't work with disabling/enabling policies
2 participants